﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsFormsApplication2.ServiceReference1;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
     public   Service1Client svr = new Service1Client();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
            svr.startoauthCompleted += svr_startoauthCompleted;
            svr.startoauthAsync();
        }

        void svr_startoauthCompleted(object sender, startoauthCompletedEventArgs e)
        {
            string eout = e.Result.ToString();
            richTextBox1.Text += eout;
            webBrowser1.Url = new Uri(eout);

            //throw new NotImplementedException();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string codeuri = webBrowser1.Url.ToString();
            // richTextBox1.Text += codeuri;
            string codeout = codeuri.Substring(codeuri.IndexOf("code") + 5);
            richTextBox1.Text += "/n你获取到的code是" + codeout;
            svr.getaccessCompleted += svr_getaccessCompleted;
            svr.getaccessAsync(codeout);

        }

        void svr_getaccessCompleted(object sender, getaccessCompletedEventArgs e)
        {
            //throw new NotImplementedException();
            richTextBox1.Text += "getaccessCompleted";

        }

        private void button3_Click(object sender, EventArgs e)
        {
            svr.postweiboCompleted += svr_postweiboCompleted;
            string posttext = richTextBox2.Text;
            svr.postweiboAsync(posttext);
        }

        void svr_postweiboCompleted(object sender, postweiboCompletedEventArgs e)
        {
            //throw new NotImplementedException();
            richTextBox1.Text += "postweiboCompleted";

        }

    }
}
